/**
 * @Author: lusx
 * @Date:   26-02-2019 05:10:26
 * @Project: Govern督办
 * @Last modified by:   lusx
 * @Last modified time: 20-03-2019 05:58:52
 */

import React  from 'react';
import Right from '../governTools/comRight/right'

//嵌套权限页面
const HOCcomponent = (WrappedComponent) =>
  class extends WrappedComponent {
    render() {
      const parentElements = super.render();
      const { isright, iscommentright } = parentElements.props;
      const style = {
        // paddingTop: (isright ===1 ? '90px' : ''),
        height: 'calc(100% - 90px)',
        position: 'fixed',
        width: '100%',
        top: '90px',
        bottom: '47px',
        overflow: 'auto',
      }
      const elements = (
        <div className='g-hocComponent' style={style}>
          {this.getRightDom(isright, iscommentright, parentElements)}
        </div>
      )
      const newElements = React.cloneElement(elements, elements.props, elements.props.children)
      return newElements
    }
    getRightDom = (isright, iscommentright, parentElements) => {
      if (isright === 1) {
        if (parentElements.props.hasOwnProperty('isopioion')) {//路由切换到评论页面
          if (iscommentright === 1) {
            return parentElements
          } else {
            return <Right />
          }
        } else {
          return parentElements
        }
      } else {
        return <Right />
      }
    }
  }
export default HOCcomponent;
